<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
	<TITLE> ZTREE DEMO - checkbox</TITLE>
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" href="${path }/js/ztree/css/demo.css" type="text/css">
	<link rel="stylesheet" href="${path }/js/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
	<!-- <script type="text/javascript" src="js/ztree/js/jquery-1.4.4.min.js"></script> -->
	<script type="text/javascript" src="${path }/js/ztree/js/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="${path }/js/ztree/js/jquery.ztree.excheck.js"></script>

	<SCRIPT type="text/javascript">
		$(function(){
			var setting = {
					check: {
						enable: true
					},
					data: {
						simpleData: {
							enable: true
						}
					}
				};
				//获得json对象数组
				var zNodes = ${zNodes};
				$.fn.zTree.init($("#treeDemo"), setting, zNodes);
		})
		function erpGrant(roleId){
			
			
			//获得树的对象
			var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
			//获得被勾选的节点
			var nodes = treeObj.getCheckedNodes(true);
			var  menuIds = "";
			for(var i = 0 ; i < nodes.length; i++){
				menuIds = menuIds + nodes[i].id+ ",";
			}

			var flag = "";
			$.ajax({
				url:"${path}/role_grantPerm",
				type:"post",
				dataType:"text",
				async:false,//设置ajax同步
				data:{
					roleId:roleId,
					menuIds:menuIds
				},
				success:function(responseText){
					flag = responseText;
				}
			});
			return flag;
		}
			
		//-->
	</SCRIPT>
</HEAD>

<BODY>
<div class="content_wrap" style="height: 500px;">
	<div class="zTreeDemoBackground left" style="height: 490px;">
		<ul id="treeDemo" class="ztree" style="height: 450px;"></ul>
	</div>
	
</div>
</BODY>
</HTML>